﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <title>JBuss 后台 - 主页</title>

    <!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link rel="shortcut icon" href="img/favicon.ico">
    <link href="css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <!--link href="js/plugins/layui/css/layui.css" rel="stylesheet"-->
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/style.min.css?v=4.0.0" rel="stylesheet">
    <link href="css/plugins/toastr/toastr.min.css" rel="stylesheet">
</head>

<body class="fixed-sidebar full-height-layout gray-bg" style="overflow:hidden">
    <div id="wrapper">
        <!--左侧导航开始-->
        <nav class="navbar-default navbar-static-side" role="navigation">
	<div id="myUR" class="nav-header">
<div class="dropdown profile-element" style="text-align:center;">
	<span><img width="70px" height="70px" alt="image" notFoundSrc="img/notFound.jpg" class="img-circle" src="/img/profile_small.jpg" /></span>
	<a data-toggle="dropdown" class="dropdown-toggle" href="#">
		<span class="clear">
	   <span class="block m-t-xs"><strong class="font-bold"></strong></span>
		<span class="text-muted text-xs block">超级管理员<b class="caret"></b></span>
		</span>
	</a>
	<ul class="dropdown-menu animated fadeInRight m-t-xs">
		<li><a class="J_menuItem" href="profile.html">个人资料</a>
		</li>
		<li class="divider"></li>
		<li><a href="javascript:logout();">安全退出</a>
		</li>
	</ul>
</div>
<div class="logo-element">JBuss+
</div>
</div>
            <div class="nav-close"><i class="fa fa-times-circle"></i>
            </div>
            <div class="sidebar-collapse">

                <ul class="nav" id="side-menu">

<!--
                    <li>
                        <a href="#"><i class="fa fa-edit"></i> <span class="nav-label">表单</span><span class="fa arrow"></span></a>
                        <ul class="nav nav-second-level">
                            <li>
                                <a href="#">文件上传 <span class="fa arrow"></span></a>
                                <ul class="nav nav-third-level">
                                    <li><a class="J_menuItem" href="form_webuploader.html">百度WebUploader</a>
                                    </li>
                                    <li><a class="J_menuItem" href="form_file_upload.html">DropzoneJS</a>
                                    </li>
                                    <li><a class="J_menuItem" href="form_avatar.html">头像裁剪上传</a>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                    </li>
-->
                </ul>
            </div>
        </nav>
        <!--左侧导航结束-->
        <!--右侧部分开始-->
        <div id="page-wrapper" class="gray-bg dashbard-1">
            <div class="row border-bottom">
                <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
                    <div class="navbar-header" style="width: 40%;">
                        <a class="navbar-minimalize1 minimalize-styl-2 btn btn-primary" href="#">
                            <i class="fa fa-bars"></i>
                        </a>
                    </div>
                    <div id="expireTimeInfo" style="float:left;width: 35%;text-align: center;line-height: 60px"></div>
                    <ul class="nav navbar-top-links navbar-right" style="width: 25%;text-align: right;">
                        <li>
						<a href="https://gitee.com/insteresting/JBuss" target="_blank">
                            <i class="fa fa-git"></i>JBuss源码
                        </a>
						</li>
                        <li class="dropdown hidden-xs">
							<a href="javascript:logout();" >
								<i class="fa fa-sign-out"></i>安全退出
							</a>
                        </li>
                    </ul>
                </nav>
            </div>
            <div class="row content-tabs">
                <button class="roll-nav roll-left J_tabLeft"><i class="fa fa-backward"></i>
                </button>
                <nav class="page-tabs J_menuTabs">
                    <div class="page-tabs-content">
                        <a href="javascript:;" class="active J_menuTab" data-id="first.html">我的</a>
                    </div>
                </nav>
                <button class="roll-nav roll-right J_tabRight"><i class="fa fa-forward"></i>
                </button>
                <div class="btn-group roll-nav roll-right">
                    <button class="dropdown J_tabClose" data-toggle="dropdown">关闭操作<span class="caret"></span>

                    </button>
                    <ul role="menu" class="dropdown-menu dropdown-menu-right">
                        <li class="J_tabShowActive"><a>定位当前选项卡</a>
                        </li>
                        <li class="divider"></li>
                        <li class="J_tabCloseAll"><a>关闭全部选项卡</a>
                        </li>
                        <li class="J_tabCloseOther"><a>关闭其他选项卡</a>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="row J_mainContent" id="content-main">
                <iframe class="J_iframe" name="iframe0" width="100%" height="100%" src="first.html" frameborder="0" data-id="first.html" seamless></iframe>
            </div>
            <div class="footer">
				<div class="pull-left" style="color:red;font-size:12px;">
                </div>
                <div class="pull-right">&copy; 2020 <a href="https://www.sudo.ren" target="_blank">为道日损</a>
                </div>
            </div>
        </div>
        <!--右侧部分结束-->
    </div>
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/popper.min.js"></script>
    <script src="js/bootstrap.min.js?v=3.3.5"></script>
    <script src="js/jquery.lazyload.min.js"></script>
    <script src="js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>

    <script src="js/plugins/pace/pace.min.js"></script>
	<script src="js/plugins/layui/layer/layer.js"></script>
	<script src="js/plugins/toastr/toastr.min.js"></script>
    <script type="text/javascript" src="js/custom/tools.js" charset="UTF-8"></script>
    <script type="text/javascript" src="js/custom/app.js" charset="UTF-8"></script>
	<script>

		$(function(){
            if (app.isUserTokenRight()){
                getMySimpleInfo();
                queryMySysMenu();
            }else{
                setInterval(function(){
                    window.location.href = "login.html";
                },3000);
                top.toastr.warning("用户信息已失效，请重新登录");
			    return false;
			}

			document.addEventListener("error", function (e) {
                const elem = e.target;
                if (elem.tagName.toLowerCase() === 'img') {
                    const notFoundImgSrt = $(elem).attr("notFoundSrc");
                    if (notFoundImgSrt) {
           				 $.get(notFoundImgSrt, null, function (response, status, xhr) {
               				 if (xhr.status === 200)
                    				elem.src = notFoundImgSrt;
           				 });
        				}
    				}
			}, true);
		})

        function queryMySysMenu(){
            const url = 'sysMenu/queryMySysMenu';
            jQuery.ajax({
                url:domain + url,
                type:"get",
                data:{},
                crossDomain:true,
                async:false,
                xhrFields:{
                    withCredentials:true
                },
                success:function (data) {
                    if(data.status == 200){
                        combHTML(data.data);
                        getMyExpirationInfo();
                    }else{
                        top.toastr.warning(data.msg);
                    }
                },
                error:function(data) {
                    top.toastr.error("菜单加载失败，请检查网络");
                }
            })
        }
		function getMySimpleInfo(){
			var url = '/sysUser/getMySimpleUserInfo';
			var bool = true;
			jQuery.ajax({
				url:domain + url,
				type:"get",
				crossDomain:true,
				async:false,
				xhrFields:{
					withCredentials:true
				},
				success:function (data) {
					if(data.status == 200){
						combMyInfoHTML(data.data);
					}else{
						bool = false;
						top.toastr.warning(data.msg);
						return;
					}
				},
				error:function(data) {
					bool = false;
					top.toastr.error("查询失败，请检查网络");
				}
			})
			return bool;
		}

		function logout(){
			//layui.use(['layer'], function(){
				//var layer = layui.layer;
				layer.confirm('确定退出？', {
					title:false,
					icon:7,
					btn: ["确定",'取消'] //按钮
				}, function(){
					var url = 'sysUser/logout';
					jQuery.ajax({
						url:domain + url,
						type:"post",
						crossDomain:true,
						xhrFields:{
							withCredentials:true
						},
						success:function (data) {
                            if (data.status == 200){
                                window.location.href = "login.html";
                            }else{
                                top.toastr.warning(data.msg);
                            }
						},
						error:function(data) {
							top.toastr.error("退出失败，请检查网络");
						}
					})
				})
			//})
		}

		function combHTML(data){
			var htmls = new Array();
			for(var i = 0;i<data.length;i++){
				if(data[i].pCode == "0000"){
					var c1 = data[i].mCode;
					var c1name = data[i].mName;
					var c1icon = data[i].mIcon;
					htmls.push('<li><a href="#"><i class="fa '+ c1icon +'"></i> <span class="nav-label">'+ c1name +'</span><span class="fa arrow"></span></a>');
					htmls.push('		<ul class="nav nav-second-level">');

					for(var j = 0;j<data.length;j++){
						if(data[j].pCode == c1){
							var c2 = data[j].mCode;
							var c2name = data[j].mName;
							var c2icon = data[j].mIcon;
							var c2murl = data[j].mUrl;
							var c2note = data[j].note;
							htmls.push('	<li><a class="J_menuItem" data-note="'+ c2note +'" onclick="showNote(this)" href="'+ c2murl +'">'+ c2name +'</a>');

							if(!!c2murl) {
								htmls.push('</li>');
								continue;
							}
							htmls.push('		<ul class="nav nav-third-level">');

							for(var k = 0;k<data.length;k++){
								if(data[k].pCode == c2){
									var c3 = data[k].mCode;
									var c3name = data[k].mName;
									var c3icon = data[k].mIcon;
									var c3murl = data[k].mUrl;
									var c3note = data[k].note;

									htmls.push('<li><a class="J_menuItem" data-note="'+ c3note +'" onclick="showNote(this)" href="'+ c3murl +'">' + c3name + '</a></li>');
								}
							}
							htmls.push('		</ul>');
							htmls.push('	</li>');
						}

					}
					htmls.push('		</ul>');
					htmls.push('</li>');
				}

			}
			$("#side-menu").html(htmls.join(''));
			//htmls.push('<script type="text/javascript" src="js/plugins/metisMenu/jquery.metisMenu.js"><\/script>');//ifram切换
			//htmls.push('<script src="js/hplus.min.js?v=4.0.0"><\/script>');

			setTimeout(loadScript,0);
		}

		function showNote(obj){
			$(".footer .pull-left").html($(obj).data("note"));
		}

		function loadScript(){
			var script = document.createElement("script");
			script.src="js/contabs.min.js";	//左侧导航菜单折叠
			document.body.appendChild(script);

			//var script1 = document.createElement("script");
			//script1.src="js/plugins/metisMenu/jquery.metisMenu.js";	//ifram切换
			//document.body.appendChild(script1);

			var script2 = document.createElement("script");
			script2.src="js/hplus.min.js?v=4.0.0";
			document.body.appendChild(script2);

			setTimeout(function (){
                var script3 = document.createElement("script");
                script3.src="js/inspinia.js";
                document.body.appendChild(script3);
            },1000);

		}

		function combMyInfoHTML(data){
			$("#myUR").find(".font-bold").html(data.nickName);
			$("#myUR").find(".text-muted").html(data.roleName);
			$("#myUR").find(".img-circle").attr("src",domain+data.profilePhoto+"?t="+Math.random());

		}

        function getMyExpirationInfo(){
            const url = '/sysAutoRole/getMyExpirationInfo';
            jQuery.ajax({
                url:domain + url,
                type:"get",
                crossDomain:true,
                async:false,
                xhrFields:{
                    withCredentials:true
                },
                success:function (data) {
                    if(data.status == 200){
                        $("#expireTimeInfo").html(data.msg);
                    }else{
                        top.toastr.warning(data.msg);
                    }
                },
                error:function(data) {
                    top.toastr.error("查询失败，请检查网络");
                }
            })
        }
	</script>
</body>

</html>
